﻿using B.S.Filtration.ErrorCode;
using B.S.Filtration.Write.Api.Application.Command.ContactPhone;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Filtration.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ContactPhoneController : ControllerBase
    {

        private readonly IMediator mediator;

        public ContactPhoneController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加联系方式
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> Handle(AddContactPhoneCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改联系方式
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdateContactPhone(UpdateContactPhoneCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
